//
//  FeedBackViewController.m
//  one·一个  tyw
//
//  Created by tyw on 15/9/12.
//  Copyright (c) 2015年 tyw. All rights reserved.
//

#import "FeedBackViewController.h"
#import "DayNightLabel.h"

@interface FeedBackViewController ()

@end

@implementation FeedBackViewController {
    UITextView* _feedBackTextView;
    UITextField* _contactInfoTextField;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor clearColor];
    [self _createNavBar];
    [self _createSubViews];
}

- (void)_createNavBar {
    self.navigationItem.titleView = nil;
    self.navigationItem.title = @"用户反馈";
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"提交" style:UIBarButtonItemStylePlain target:self action:@selector(sendAction)];
}

- (void)sendAction {
    NSLog(@"提交");
    [_feedBackTextView resignFirstResponder];
    [_contactInfoTextField resignFirstResponder];
    
    [self showHUD:@"正在提交"];
    [self performSelector:@selector(test1) withObject:nil afterDelay:2];
}
- (void)test1 {
    [self completeHUD:@"提交成功"];
    [self performSelector:@selector(test2) withObject:nil afterDelay:1];
}
- (void)test2 {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)_createSubViews {
    UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight)];
    scrollView.contentSize = CGSizeMake(kWidth, kHeight);
    scrollView.scrollEnabled = YES;
    scrollView.showsVerticalScrollIndicator = NO;
    scrollView.backgroundColor = [UIColor clearColor];
    scrollView.delegate = self;
    [self.view addSubview:scrollView];
    
    DayNightLabel* topLabel = [[DayNightLabel alloc] initWithFrame:CGRectMake(20, 20, kWidth-40, 30)];
    [topLabel loadLabelColor];
    topLabel.text = @"简要说明您面临的问题，或者您认为需要改进的地方";
    topLabel.numberOfLines = 0;
    topLabel.textAlignment = NSTextAlignmentLeft;
    topLabel.font = [UIFont systemFontOfSize:12];
    [scrollView addSubview:topLabel];
    
    
    _feedBackTextView = [[UITextView alloc] initWithFrame:CGRectMake(20, 60, kWidth-40, 200)];
    _feedBackTextView.backgroundColor = [UIColor whiteColor];
    _feedBackTextView.alpha = 0.5;
    _feedBackTextView.layer.borderWidth = 1;
    _feedBackTextView.layer.borderColor = [UIColor blackColor].CGColor;
    [scrollView addSubview:_feedBackTextView];
    
    _contactInfoTextField = [[UITextField alloc] initWithFrame:CGRectMake(20, 270, kWidth-40, 30)];
    _contactInfoTextField.backgroundColor = [UIColor whiteColor];
    _contactInfoTextField.alpha = 0.5;
    _contactInfoTextField.textAlignment = NSTextAlignmentLeft;
    _contactInfoTextField.font = [UIFont systemFontOfSize:15];
    _contactInfoTextField.layer.borderWidth = 1;
    _contactInfoTextField.layer.borderColor = [UIColor blackColor].CGColor;
    _contactInfoTextField.placeholder = @"联系方式，建议邮箱或手机，可不填";
    [scrollView addSubview:_contactInfoTextField];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    [_feedBackTextView resignFirstResponder];
    [_contactInfoTextField resignFirstResponder];
}

@end
